﻿Imports Sy.Data
Namespace Client.Upload.Init
    Public Class Init
        Inherits AbsApi
        Public Overrides ReadOnly Property Action As String
            Get
                Return "client/import/init"
            End Get
        End Property
        Private ReadOnly Data As Request
        Public Sub New(ReportData As String)
            Data = New Request(ReportData)
        End Sub
        Public Response As Response
        Public Function [Post](UILog As LogSub) As Boolean
            Dim Log = GetLoger(UILog)
            If Core.Instance.Invoke(Me, Data, Log) = TryResult.Success Then
                Return True
            Else
                Return False
            End If
        End Function
        Public Overrides Function DealSuccess(Result As Integer, Data As String, Log As LogSub) As TryResult
            Response = JsonObject.DeserializeSafety(Of Response)(Data)
            If Response.IsNotNull Then
                Return TryResult.Success
            Else
                Return TryResult.Fail
            End If
        End Function
        Public Overrides Function Deal(Result As Integer, Data As String, Log As LogSub) As TryResult
            Dim r As Results
            If [Enum].IsDefined(GetType(Results), Result) AndAlso [Enum].TryParse(Result, r) Then
                Log($"{r.GetDescription()}")
            Else
                Log($"Error Client.Upload.Init.Init(Result=[{Result}])")
                Return TryResult.ReTry
            End If
            Return TryResult.Fail
        End Function
    End Class
End Namespace
